<?php
	// get the HTML

	include CHEMIN_MODELE.'get_annee_scolaire.php';

	if(!$_GET['archive'])
	{
		$adc = new ActionDeCommunication($_GET[ID_ADC]);
		$adc->getOneADC();
		$etudiants = $adc->get_etudiants_ADC();
		$taches = Tache::getAllTacheADC($_GET[ID_ADC]);
		$depenses = Depense::getAllDepense($_GET[ID_ADC]);
		$recettes = Recette::getAllRecette($_GET[ID_ADC]);
		$fba = new FicheBilanAction($_GET[ID_ADC]);
		$fba->getOneFicheBilanAction();
	}
	else
	{
		$adc = new ActionDeCommunication($_GET[ID_ADC]);
		$adc->getOneADCFromArchive();
		$etudiants = $adc->get_etudiants_ADCFromArchive();
		$taches = Tache::getAllTacheADCFromArchive($_GET[ID_ADC]);
		$depenses = Depense::getAllDepenseFromArchive($_GET[ID_ADC]);
		$recettes = Recette::getAllRecetteFromArchive($_GET[ID_ADC]);
		$fba = new FicheBilanAction($_GET[ID_ADC]);
		$fba->getOneFicheBilanActionFromArchive();
	}

	$annee_scolaire = get_annee_scolaire($adc->get_date_deroulement());
	$code_adc = $adc->get_code();

	ob_start();
	include(CHEMIN_VUE.'templateFicheBilanADC.php');
	$content = ob_get_clean();

	require_once(CHEMIN_LIB.'html2pdf_v4.03/html2pdf.class.php');
	// convert in PDF
	try
	{
		$html2pdf = new HTML2PDF('P', 'A4', 'fr', true, 'UTF-8', 20);
		$html2pdf->setDefaultFont('Arial');
		$html2pdf->writeHTML($content);
		$html2pdf->Output($code_adc.'_-_'.$annee_scolaire.'.pdf', 'D');
	}
	catch(HTML2PDF_exception $e)
	{
		echo $e;
		exit;
	}
	exit;
?>